"""
    有一家公司有如下几种岗位：
        -- 程序员：底薪 + 项目分红
        -- 测试员：底薪 + Bug数*5
    创建员工管理器：
        -- 记录所有员工
        -- 计算所有员工总薪资

    封装：程序员 测试员 员工管理器
    继承：
    多态：
"""

class EmployeeManager:
    def __init__(self):
        self.__employee_list = []

    def add_employee(self,new):
        if isinstance(new,Employee):
            self.__employee_list.append(new)

    def calculate_all_emp_salary(self):
        # 计算所有员工工资
        total = 0
        for item in self.__employee_list:
            total += item.calculate_salary()
        return total


class Employee:
    def __init__(self,basic_salary=4000):
        self.basic_salary = basic_salary

    def calculate_salary(self):
        return self.basic_salary

class Programmer(Employee):
    def __init__(self,basic_salary=4000,project_salary=0):
        super().__init__(basic_salary)
        self.project_salary = project_salary

    def calculate_salary(self):
        return super().calculate_salary() + self.project_salary

class TestControler(Employee):
    def __init__(self,basic_salary=3500,bug_sum=0):
        super().__init__(basic_salary)
        self.bug_sum = bug_sum

    def calculate_salary(self):
        return super().calculate_salary() + self.bug_sum * 50

em = EmployeeManager()
p1 = Programmer(5000,1000)
p2 = Programmer(6000,3000)
p3 = Programmer(3000,2000)
em.add_employee(p1)
em.add_employee(p2)
em.add_employee(p3)
t1 = TestControler(3500,100)
t2 = TestControler(4000,150)
t3 = TestControler(3500,180)
em.add_employee(t1)
em.add_employee(t2)
em.add_employee(t3)

print(em.calculate_all_emp_salary())
